package com.wut.core.common.vo;

import com.github.pagehelper.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("分页响应参数")
public class PageResponse<T> implements Serializable {

    @ApiModelProperty(value = "数据", example = "")
    private List<T> list;
    @ApiModelProperty(value = "页码", example = "1")
    private Integer pageNum;
    @ApiModelProperty(value = "每页大小", example = "10")
    private Integer pageSize;
    @ApiModelProperty(value = "总条数", example = "200")
    private Long total;

    public PageResponse(List<T> list) {
        Page<T> page = (Page<T>) list;
        this.list = page.getResult();
        this.pageNum = page.getPageNum();
        this.pageSize = page.getPageSize();
        this.total = page.getTotal();
    }

    public PageResponse(List pageList, List<T> list) {
        Page page = (Page) pageList;
        this.list = list;
        this.pageNum = page.getPageNum();
        this.pageSize = page.getPageSize();
        this.total = page.getTotal();
    }

    private static final long serialVersionUID = 1L;
}